﻿@namespace BlazorDemos.Shared

@if (Visible)
{
    <div class='sb-sample-description sb-rightpane-padding'>
        @ChildContent   
    </div>
}

@code {
    [CascadingParameter]
    protected RightPaneComponent RightPane { get; set; }

    /// <summary>
    /// Child content of ActionDescription component.
    /// </summary>
    [Parameter]
    public RenderFragment ChildContent { get; set; }

    /// <summary>
    /// Specifies the visibility of the component.
    /// This can be set true only in RightPane layout page.
    /// </summary>
    [Parameter]
    public bool Visible { get; set; }

    /// <summary>
    /// Re-rendering the component with description.
    /// </summary>
    public void Refresh()
    {
        StateHasChanged();
    }
    
    protected override void OnParametersSet()
    {
        base.OnParametersSet();
        // Set sample description to RightPanel's sample description for rendering in the layout.
        if (!Visible)
        {
            RightPane?.RefreshSampleDescription(ChildContent);
        }
    }
}
